package org.gol.paxos;

import java.util.ArrayList;
import java.util.List;

/**
 * @package org.gol.paxos
 * @description 【提案】 提案之间 能比较结果
 * @author Goliath
 * @createTime 2012-11-21 下午1:40:48
 * @modifyTime
 */
public class Proposal implements Cloneable {
	public static final int DISAGREE = -1;
	public static final int INIT = 0;
	public static final int SENDED = 1;
	public static final int AGREE = 2;
	public static final int CONFIRM = 3;

	public Proposal(String content) {
		this.content = content;
	}

	public String toString() {

		return "[proNo:" + proNo + ",content:" + content + ",result:" + result + "]";
	}

	@SuppressWarnings("unused")
	private String trans(int state) {
		if (state == -1) {
			return "DISAGREE";
		} else if (state == 0) {
			return "INIT";
		} else if (state == 1) {
			return "SENDED";
		} else if (state == 2) {
			return "AGREE";
		} else if (state == 3) {
			return "CONFIRM";
		} else {
			return "";
		}
	}

	/**
	 * 提案的编号
	 */
	private String proNo;
	/**
	 * 提案的内容
	 */
	private String content;
	/**
	 * 批复人的姓名
	 */
	private String acceptorName;
	/**
	 * 提案被参议院批复后 把批复同意复印件加到原件里
	 */
	private List<Proposal> agreeCopy = new ArrayList<Proposal>();
	/**
	 * 提案被参议院批复后 把批复不同意复印件加到原件里
	 */
	private List<Proposal> disagreeCopy = new ArrayList<Proposal>();
	/**
	 * 提案的结果
	 */
	private int result;

	private String comment;
	
	/**
	 * 提案状态 初始状态时INIT
	 */
	private int state = Proposal.INIT;

	// 判定是不是同一件议题
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Proposal) {
			Proposal pCompare = (Proposal) obj;
			if (this.getContent() == null && pCompare.getContent() != null) {
				return false;
			} else {
				if (!this.getContent().equals(pCompare.getContent())) {
					return false;
				}
			}
			return true;
		}
		return false;
	}

	public String getProNo() {
		return proNo;
	}

	public void setProNo(String proNo) {
		this.proNo = proNo;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public int getResult() {
		return result;
	}

	public void setResult(int result) {
		this.result = result;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		return super.clone();
	}

	public String getAcceptorName() {
		return acceptorName;
	}

	public void setAcceptorName(String acceptorName) {
		this.acceptorName = acceptorName;
	}

	public List<Proposal> getAgreeCopy() {
		return agreeCopy;
	}

	public void setAgreeCopy(List<Proposal> agreeCopy) {
		this.agreeCopy = agreeCopy;
	}

	public List<Proposal> getDisagreeCopy() {
		return disagreeCopy;
	}

	public void setDisagreeCopy(List<Proposal> disagreeCopy) {
		this.disagreeCopy = disagreeCopy;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

}
